#include"apue.h"
using namespace std;
using namespace MC;


Managerdao_file_impl::Managerdao_file_impl(){}
void Managerdao_file_impl::load(vector<Manager>** ma)
{
	FILE* frp=fopen("./account/Manager.dat","rb+");

	if(NULL==frp)
	{
		perror("fopen");
		return;
	}
	int ret;
	Manager m;
	while(1)
	{
		ret =fread(&m,sizeof(Manager),1,frp);
		if(ret<=0)break;
		(*ma)->push_back(m);
	 
	}
	


	fclose(frp);

}

void Managerdao_file_impl::save(vector<Manager> ma)
{
	FILE* fwp=fopen("./account/Manager.dat","wb+");
	
	for(unsigned int i=0;i<ma.size();i++)
	{
		fwrite(&ma[i],sizeof(Manager),1,fwp);
	}
	fclose(fwp);
}
